﻿<%@ Page Title="到货通知订单查询" Language="C#" MasterPageFile="~/master/m.master" %>

<script runat="server"></script>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <link href="../assets/css/plugins/footable/footable.core.css" rel="stylesheet">
    <link href="../assets/css/shelf/base.css" rel="stylesheet">
    <link href="../assets/css/plugins/webuploader/webuploader.css" rel="stylesheet" />
    <link href="../assets/img/validate/validate.css" rel="stylesheet">
    <link href="../assets/css/enterpriseLayout/makePlan.css" rel="stylesheet">
    <link href="../assets/css/plugins/stepper/stepper.widget.css" rel="stylesheet" />
    <link href="../assets/css/plugins/iCheck/customsmall.css" rel="stylesheet" />
    <link href="../assets/img/validate/validate.css" rel="stylesheet">
    <style>
        .condition, .module-info .form-group {
            padding: 3px 0;
        }

        .module-info .form-group {
            margin: 0;
            overflow: hidden;
        }

            .module-info .form-group .control-label, .module-info .form-group .form-control {
                float: left;
            }

        .inmodal .modal-body {
            padding: 10px 10px 8px 10px;
        }

        #sizeTable {
            border-left: 1px solid #dfdfdd;
            border-top: 1px solid #dfdfdd;
        }

            #sizeTable th, #sizeTable td {
                width: 40px;
                text-align: center;
                border-right: 1px solid #dfdfdd;
                border-bottom: 1px solid #dfdfdd;
                height: 30px;
                line-height: 30px;
            }

            #sizeTable .inputSize {
                width: 100%;
                height: 100%;
                border: 0;
                text-align: center;
                margin: 0;
            }

        @media (min-width: 768px) {
            .modal-dialog {
                width: 768px;
                margin: 30px auto;
            }
        }

        .condition, .condition-title {
            border-bottom: 1px solid #dfdfdd;
        }
        /*所有表格行高缩小*/
        .table > tbody > tr > td, .table > tbody > tr > th, .table > tfoot > tr > td, .table > tfoot > tr > th, .table > thead > tr > td, .table > thead > tr > th {
            padding: 5px;
        }
        /*.label {
            background-color: #d1dade;
            color: #5e5e5e;
            font-size: 10px;
            font-weight: 600;
            text-shadow: none;
            padding: 0px 6px;
        }*/
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="main" runat="Server">
    <div class="system-box">
        <div class="right-side">
            <div class="btns-container">
                <div class="modal inmodal" id="addWindow" tabindex="-1" role="dialog" aria-hidden="true">
                    <form id="checkModuleForm" method="get" action="#">
                    </form>
                </div>
            </div>
            <div class="condition">
                <label>到货通知单号:</label>
                <input id="search-billNo" class="form-control input-w170" placeholder="输入到货通知单号" />
                <label>货号:</label>
                <input id="search-MaterialID" class="form-control input-w170" placeholder="输入货号" />
                <div class="pull-left center" style="line-height: 34px">
                    <input id="search-billTime" type="radio" name="time" />开单时间
                    <input id="search-workTime" type="radio" name="time" />生效时间
                </div>
                <input type="text" class="form-control layer-date" readonly="readonly" id="search-start" placeholder="开始时间" />
                <label class="to">到</label>
                <input type="text" class="form-control layer-date" readonly="readonly" id="search-end" placeholder="结束时间" />
            </div>
            <div style="overflow: auto; background: #fff; padding: 0 1px;">
                <%--<div class="tb-head-container">
				<table class="loadTable">
				</table>
			</div>--%>
                <div class="tb-body-container">
                    <table class="loadTable   table table-stripped">
                        <thead></thead>
                        <tbody id="pageList"></tbody>
                    </table>
                </div>
            </div>
            <div class="pageControl"></div>
        </div>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="footer" runat="Server">
    <script src="../assets/js/plugins/layer/laydate/laydate.js"></script>
    <script src="../assets/js/page/pageControl.js"></script>
    <script src="../assets/js/page/rScroll.js"></script>
    <script src="../assets/js/page/tableControl.js"></script>
    <script src="../assets/js/plugins/iCheck/icheck.min.js"></script>
    <script src="../assets/js/plugins/iCheck/icheckAll.js"></script>
    <script src="../assets/js/plugins/webuploader/webuploader.min.js"></script>
    <script src="../assets/js/framework.js"></script>
    <script src="../assets/img/validate/learunui-validator.js"></script>
    <script>
        $(document).ready(function () {

            //初始化日期控件
            var start = {
                elem: "#search-start",
                format: "YYYY-MM-DD",
                min: "2015-12-01",
                max: "2099-12-01",
                istime: true,
                istoday: false,
                choose: function (datas) {
                    end.min = datas;
                    end.start = datas
                }
            };
            var end = {
                elem: "#search-end",
                format: "YYYY-MM-DD",
                min: laydate.now(),
                max: "2099-12-01",
                istime: true,
                istoday: false,
                choose: function (datas) {
                    start.max = datas
                }
            };
            laydate(start);
            laydate(end);

            var ModuleID = Y.getUrlParam("ModuleID");
            var page = 1;
            //获取按钮
            commonUtil.loadBtnList(ModuleID, function () {
                $('#editBtn').attr('disabled', 'disabled');
            });

            Date.prototype.Format2 = function (fmt) { //author: meizz 
                var o = {
                    "M+": this.getMonth() + 1, //月份 
                    "d+": this.getDate(), //日 
                    "h+": this.getHours(), //小时 
                    "m+": this.getMinutes(), //分 
                    "s+": this.getSeconds(), //秒 
                    "q+": Math.floor((this.getMonth() + 3) / 3), //季度 
                    "S": this.getMilliseconds() //毫秒 
                };
                if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
                for (var k in o)
                    if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
                return fmt;
            }

            var FormatDate = function (d) {
                if (d == null || d == undefined || d == "" || d == "0001-01-01T00:00:00") {
                    return "";
                }
                return new Date(d).Format2("yyyy-MM-dd");
            }

            var GetNoticeFlagColor = function (state) {
                switch (state) {
                    case "未送审":
                        return "label label-default";
                    case "已退审":
                        return "label label-warning";
                    case "已生效":
                        return "label label-success";
                    default:
                        return "";
                }
               
            };
            //处理表头
            tableControl.initThead('.tb-body-container  .loadTable', [{
                trClass:'', children: [
                    { tdText: '', c: 0, r: 0, tdHtml: '<span style="display:inline-block; width:46px;"><input type="checkbox" id="checkAll" /></span>', tdId: '', tdClass: 'diy-td-w46 hide' },
                    { tdText: '', c: 0, r: 0, tdHtml: '<span style="display:inline-block; width:72px;">开单时间</span>', tdId: '', tdClass: 'diy-td-w72' },
                    { tdText: '', c: 0, r: 0, tdHtml: '<span style="display:inline-block; width:120px;">到货通知单号</span>', tdId: '', tdClass: 'diy-td-w120' },
                    { tdText: '', c: 0, r: 0, tdHtml: '<span style="display:inline-block; width:72px;">货号</span>', tdId: '', tdClass: 'diy-td-w72' },
                    { tdText: '', c: 0, r: 0, tdHtml: '<span style="display:inline-block; width:72px;">订单总数量</span>', tdId: '', tdClass: 'diy-td-w72' },
                    { tdText: '', c: 0, r: 0, tdHtml: '<span style="display:inline-block; width:100px;">生产加工单</span>', tdId: '', tdClass: 'diy-td-w100' },
                    { tdText: '', c: 0, r: 0, tdHtml: '<span style="display:inline-block; width:52px;">单号状态</span>', tdId: '', tdClass: 'diy-td-w50' },
                    { tdText: '', c: 0, r: 0, tdHtml: '<span style="display:inline-block; width:72px;">生效时间</span>', tdId: '', tdClass: 'diy-td-w72' },
                ]
            }])

            //获取浏览器类型
            var sUserAgent = navigator.userAgent.toLowerCase();
            //计算容器大小
            var calcContainer = function () {
                //计算表格高度
                $('.tb-body-container').height(
                    $('.right-side').height() - $('.condition').outerHeight() -
                    $('.tb-head-container').outerHeight() - (sUserAgent.indexOf('chrome') > -1 ? 70 : 79));
            }
            $(window).resize(function () {
                //重新计算容器高度
                calcContainer();
            });

            var loadList = function () {
                 var time = "-1";
                if ($('#search-billTime').is(':checked')) {
                    time = "0";
                }
                else if ($('#search-workTime').is(':checked')) {
                    time = "1";
                }
                pageControl.init('ArrivalNotice', 'GetList', {
                    billNo: $('#search-billNo').val(),
                    MaterialID: $('#search-MaterialID').val(),
                    BeginDate: $('#search-start').val(),
                    EndDate: $('#search-end').val(),
                    Time: time,
                    Page: page,
                    Size: 50,
                    needLayer: true,
                    alwaysCallBack: function () {
                        //$('#pageList').empty();
                    }
                }, function (result) {
                    //pageList = [];
                    page = result.page;
                    var tBody = [];
                    if (!Y.checkNull(result.data)) {
                        if (result.data.Items.length > 0) {
                            dataList = result.data.Items;
                            var IsEmpty = '0';
                            result.data.Items.map(function (item, i) {
                                var tempChild = [];
                                tempChild.push({
                                    tdText: '',
                                    c: 0,
                                    r: 0,
                                    tdHtml:
                                        '<input type="checkbox" class="checkPlan" data-index="' +
                                            i +
                                            '" />',
                                    tdId: '',
                                    tdClass: 'hide'
                                });
                                tempChild.push({
                                    tdText: '',
                                    c: 0,
                                    r: 0,
                                    tdHtml: '<span style="display:inline-block; width:72px">' +
                                    FormatDate(item.BillDate) +
                                        '</span>',
                                    tdId: '',
                                    tdClass: 'BillDate'
                                });
                                tempChild.push({
                                    tdText: '',
                                    c: 0,
                                    r: 0,
                                    tdHtml: '<span style="display:inline-block; width:90%;">' + (item.BillNo || IsEmpty) + '</span>',
                                    tdId: '',
                                    tdClass: 'BillNo'
                                });
                                tempChild.push({
                                    tdText: '',
                                    c: 0,
                                    r: 0,
                                    tdHtml: '<span style="display:inline-block; width:100%;">' + (item.MaterialID || IsEmpty) + '</span>',
                                    tdId: '',
                                    tdClass: 'MaterialID'
                                });

                                tempChild.push({
                                    tdText: '',
                                    c: 0,
                                    r: 0,
                                    tdHtml: '<span style="display:inline-block; width:50%;">' + (item.Qty || IsEmpty) + '</span>',
                                    tdId: '',
                                    tdClass: 'Qty'
                                });

                                tempChild.push({
                                    tdText: '',
                                    c: 0,
                                    r: 0,
                                    tdHtml: '<span style="display:inline-block; width:100%;">' + (item.SourceBillNo || IsEmpty) + '</span>',
                                    tdId: '',
                                    tdClass: 'SourceBillNo'
                                });

                                tempChild.push({
                                    tdText: '',
                                    c: 0,
                                    r: 0,
                                    tdHtml: '<span style="display:inline-block; width:50%;"><lable class="' + GetNoticeFlagColor(item.CNStateName) + '">'+item.CNStateName+'</lable></span>',
                                    tdId: '',
                                    tdClass: 'CNStateName'
                                });

                                tempChild.push({
                                    tdText: '',
                                    c: 0,
                                    r: 0,
                                    tdHtml: '<span style="display:inline-block; width:100%;">' + FormatDate(item.CheckDate) + '</span>',
                                    tdId: '',
                                    tdClass: 'CheckDate'
                                });
                                var tempTr = {
                                    trClass: (i % 2 == 0 ? 'gradeX footable-even' : 'gradeX footable-odd') ,
                                    children: tempChild
                                };
                                tBody.push(tempTr);
                            });
                        }
                        rScroll();
                    }
                    tableControl.initTbody('.tb-body-container  .loadTable', (tBody.length > 0 ? tBody : null), 13, null);
                })
            }
            loadList();
            //查询按钮
            $(".btns-container").on('click',
                '#btn-search',
                function() {
                    page = 1;
                    loadList();
                });

        })
    </script>
</asp:Content>

